<template>
  <div class="calendar-info">
    <div class="nav-common-title">
      <i class="el-icon-user-solid"></i>
      <span>日历</span>
    </div>
    <div class="nav-common-content">
      <el-calendar v-if="calendarMounth.length" :range="calendarMounth">
      </el-calendar>
      <!-- <el-calendar :range="['2019-03-04', '2019-03-24']"> </el-calendar> -->
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      calendarMounth: []
    }
  },
  mounted() {
    let date = new Date()
    let year = date.getFullYear()
    let month = date.getMonth() + 1
    let endDate = this.getCountDays(month)
    month = month + ''
    this.calendarMounth = [
      `${year}-${month.padStart(2, '0')}-01`,
      `${year}-${month.padStart(2, '0')}-${endDate}`
    ]
  },
  methods: {
    getCountDays(month) {
      let curDate = new Date()
      curDate.setMonth(month)
      curDate.setDate(0)
      return curDate.getDate()
    }
  }
}
</script>

<style lang="less">
.calendar-info {
  margin-top: 20px;
  background: #fff;

  .el-calendar-day {
    height: 50px;
  }

  .el-calendar__header {
    display: none;
  }
}
</style>
